<?xml version="1.0" encoding="ISO-8859-2" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui"
	xmlns:spring="http://www.springframework.org/tags">

<h:head>

</h:head>
<h:body>
	<h:form id="form">
		<p:dataTable id="basic" var="c" value="#{countryService.countryModel}"
			selection="#{countryService.selectedCountry}" selectionMode="single"
			rowKey="#{c.code}">

			<p:ajax event="rowSelect" update="@form"
				oncomplete="countryDialog.show()" />

			<p:column headerText="Code">
				#{c.code}
			</p:column>
			<p:column headerText="Name">
				#{c.name}
			</p:column>
			<p:column headerText="Continent">
				#{c.continent}
			</p:column>
		</p:dataTable>

		<p:dialog id="dialog" header="Country details"
			widgetVar="countryDialog" resizable="false" showEffect="explode"
			hideEffect="explode">

			<h:panelGrid id="display" columns="2" cellpadding="4">
				<c:set var="imgURL"
					value="/resources/images/flags/#{countryService.selectedCountry.code2}.png" />
				<h:outputText value="#{resourceBundle.name}:" />
				<p:column style="text-align: center">
					<h:outputText value="#{countryService.selectedCountry.name}" />
					<p:graphicImage value="${fn:toLowerCase(imgURL)}" />
				</p:column>


				<h:outputText value="#{resourceBundle.code}:" />
				<h:outputText value="#{countryService.selectedCountry.code}" />

				<h:outputText value="#{resourceBundle.continent}:" />
				<h:outputText value="#{countryService.selectedCountry.continent}" />

				<h:outputText value="#{resourceBundle.region}:" />
				<h:outputText value="#{countryService.selectedCountry.region}" />

				<h:outputText value="#{resourceBundle.surfaceArea}:" />
				<h:outputText value="#{countryService.selectedCountry.surfaceArea}" />

				<h:outputText value="#{resourceBundle.independenceDate}:" />
				<h:outputText
					value="#{countryService.selectedCountry.independenceDate}" />

				<h:outputText value="#{resourceBundle.population}:" />
				<h:outputText value="#{countryService.selectedCountry.population}" />

				<h:outputText value="#{resourceBundle.lifeExpectancy}:" />
				<h:outputText
					value="#{countryService.selectedCountry.lifeExpectancy}" />

				<h:outputText value="#{resourceBundle.GNP}:" />
				<h:outputText value="#{countryService.selectedCountry.GNP}" />

				<h:outputText value="#{resourceBundle.governmentForm}:" />
				<h:outputText
					value="#{countryService.selectedCountry.governmentForm}" />

				<h:outputText value="#{resourceBundle.headOfState}:" />
				<h:outputText value="#{countryService.selectedCountry.headOfState}" />

				<h:outputText value="#{resourceBundle.capital}:" />
				<h:outputText value="#{countryService.selectedCountry.capital.name}" />

				<h:outputText value="#{resourceBundle.code2}:" />
				<h:outputText value="#{countryService.selectedCountry.code2}" />

			</h:panelGrid>

			<p:commandButton action="showCities" value="Show Cities" />
		</p:dialog>

	</h:form>
</h:body>
</html>
